"""Build versioned object store tests"""
import daos_build

def scons():
    """Execute build"""
    Import('denv', 'prereqs', 'utest_utils', 'conf_dir')

    libraries = ['vos', 'bio', 'abt', 'pthread', 'daos_common_pmem',
                 'daos_tests', 'gurt', 'cart', 'uuid', 'pthread',
                 'pmemobj', 'cmocka', 'gomp']

    prereqs.require(denv, 'argobots')

    # Add runtime paths for daos libraries
    denv.AppendUnique(RPATH_FULL=['$PREFIX/lib64/daos_srv'])
    vtsenv = denv.Clone()
    vtsenv.Append(CPPDEFINES={'VOS_UNIT_TEST' : '1'})

    vos_test_src = ['vos_tests.c', 'vts_io.c', 'vts_pool.c', 'vts_container.c',
                    denv.Object("vts_common.c"), 'vts_aggregate.c', 'vts_dtx.c',
                    'vts_gc.c', 'vts_checksum.c', 'vts_ilog.c', 'vts_array.c',
                    'vts_pm.c', 'vts_ts.c', '../../container/srv_csum_recalc.c',
                    'vts_mvcc.c']
    vos_tests = daos_build.program(vtsenv, 'vos_tests', vos_test_src,
                                   LIBS=libraries)
    denv.AppendUnique(CPPPATH=["../../common/tests"])
    Import('cmd_parser')
    evt_ctl = daos_build.program(denv, 'evt_ctl', ['evt_ctl.c', utest_utils,
                                 cmd_parser], LIBS=libraries)

    denv.Install('$PREFIX/bin/', [vos_tests, evt_ctl])
    denv.Install(conf_dir, ['vos_size_input.yaml'])

if __name__ == "SCons.Script":
    scons()
